package com.yxh.lib_base.ext

import android.view.Gravity
import androidx.annotation.DrawableRes
import com.blankj.utilcode.util.ResourceUtils
import com.blankj.utilcode.util.ToastUtils
import com.yxh.lib_base.R
import org.jetbrains.annotations.NotNull

/**
 * @FileName: ToastUtils.java
 * @author: villa_mou
 * @date: 08-10:14
 * @version V1.0 <描述当前版本功能>
 * @desc
 */


fun ToastUtils.showToastCenter(@NotNull msg: String, isLong: Boolean? = false) = this.setMode(ToastUtils.MODE.DARK)
        .setGravity(Gravity.CENTER, 0, 0)
                .setDurationIsLong(isLong != null && isLong)
                .show(msg)

fun ToastUtils.showToastError(@NotNull msg: String, isLong: Boolean? = false) = showToastTip(msg, R.drawable.ic_toast_notify_error, isLong)

fun ToastUtils.showToastInfo(@NotNull msg: String, isLong: Boolean? = false) = showToastTip(msg, R.drawable.ic_toast_notify_info, isLong)

fun ToastUtils.showToastSuccess(@NotNull msg: String, isLong: Boolean? = false) = showToastTip(msg, R.drawable.ic_toast_notify_done, isLong)


fun ToastUtils.showToastTip(@NotNull msg: String, @DrawableRes icon: Int, isLong: Boolean? = false) = this.setMode(ToastUtils.MODE.DARK)
        .setGravity(Gravity.CENTER, 0, 0)
        .setTopIcon(ResourceUtils.getDrawable(icon))
        .setDurationIsLong(isLong ==true)
        .setNotUseSystemToast()
        .show(msg)